package main

import (
	"TOScheduler/src/grpc"
	"TOScheduler/src/logger"
	"flag"
	"fmt"
)

var (
	sdkPort    int
	tdSocket   string
	aiPortBase int
	aiPortDiff int
	capacity   int
	tmo        int
)

func init() {
	flag.IntVar(&sdkPort, "sdk", 6575, "Port of Server for SDK (default 6575)")
	flag.StringVar(&tdSocket, "td", "IP:6580", "Socket of Server of TD (default IP:6580)")
	flag.IntVar(&aiPortBase, "base", 6585, "Base port of Server of AI (default 6585)")
	flag.IntVar(&aiPortDiff, "diff", 1, "Port difference of Server of AI [TM (FR+diff), IA (FR+2diff), ...] (default 1)")
	flag.IntVar(&capacity, "cap", 500, "Channel capacity of task channel (default 500)")
	flag.IntVar(&tmo, "tmo", 3, "Timeout threshold second of AI (default 3)")
}

func main() {
	flag.Parse()
	logger.GetLogger()
	go grpc.StartSDKServer(fmt.Sprintf("%s:%d", "0.0.0.0", sdkPort), capacity, tmo)
	go grpc.InitTDClient(tdSocket)
	go grpc.InitAIClient(aiPortBase, aiPortDiff)
	select {}
}
